package models

import (
	"gorm.io/gorm"
)

type Activity struct {
	gorm.Model
	GoodsID       int     //商品ID
	ActivityPrice float64 //火哦东价格
	Progress      string  //成团进度
	Countdown     string  //倒计时
}

func (a *Activity) AddActivity() error {
	return DB.Create(&a).Error
}

//func (a *Activity) ShowActivity(activityId int) (showActivity []ActivityInfo, err error) {
//	err = DB.
//		Table("goods").
//		Select("activities.*,goods.title as title,goods.stock as stock").
//		Joins("LEFT JOIN activities ON goods.id=activities.goods_id").
//		Where("activities.id=?", activityId).
//		Limit(1).Find(&showActivity).Error
//	return
//}

type ActivityInfo struct {
	Activity
	GoodsTitle string
	GoodsStock int64
}
